import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/common/xindong_define.dart';
import 'package:xindong/models/xindong_file_select_class.dart';
import 'package:xindong/res/assets_res.dart';
import 'package:xindong/routes/user/auth/xindong_auth_ctr.dart';
import 'package:xindong/utils/xindong_image_util.dart';
import 'package:xindong/widgets/common/xindong_app_bar.dart';
import 'package:xindong/widgets/common/xindong_button.dart';
import 'package:xindong/widgets/image/xindong_media_add_container.dart';

class XinDongAuthCarYeMian extends StatefulWidget {
  const XinDongAuthCarYeMian({super.key});

  @override
  State<XinDongAuthCarYeMian> createState() => _XinDongAuthCarYeMianState();
}

class _XinDongAuthCarYeMianState extends State<XinDongAuthCarYeMian> {
  List<XinDongSelectFileClass> fileClasss = [];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: XinDongAppBar("车辆认证"),
      body: Stack(
        children: [
          ListView(
            padding: const EdgeInsets.all(kPaddingValue),
            children: [
              const Text(
                "请按以下要求上传机动车登记证明",
                style: TextStyle(color: DZColors.titleColor, fontSize: 15),
              ),
              Padding(
                padding: const EdgeInsets.only(top: 16.0, bottom: 16.0),
                child: AspectRatio(
                  aspectRatio: 650 / 427.0,
                  child: ImageUtil.asset(AssetsRes.IMAGE_AUTH_CAR, fit: BoxFit.cover),
                ),
              ),
              const Text(
                "相关证件图片（正反2面）",
                style: TextStyle(color: DZColors.titleColor, fontSize: 15),
              ),
              SizedBox(
                child: Container(
                  alignment: Alignment.topLeft,
                  constraints: const BoxConstraints(maxWidth: 300),
                  padding: const EdgeInsets.only(top: 16.0, bottom: 16.0),
                  child: XinDongMediaAddContainer(
                    maxCount: 2,
                    supportType: MediaSupportType.onlyImage,
                    onSelect: (images, video) {
                      fileClasss = images!;
                    },
                  ),
                ),
              ),
              SizedBox(height: 25 + kButtonHeight + bottomBarHeight + 30),
            ],
          ),
          Positioned(
            bottom: 30 + bottomBarHeight,
            left: 16,
            right: 16,
            child: SizedBox(
              height: kButtonHeight,
              child: XinDongCommonButton(
                '提交',
                onTap: () => XinDongAuthCtr.to.requestAuthCar(fileClasss: fileClasss),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
